From: Jeff Kubascik Date: Tue, 21 Jan 2020 15:07:04 +0000 (-0500) Subject: xen/arm: Sign extend TimerValue when computing the CompareValue X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~808 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=3c601c5f056fba055b7a1438b84b69fc649275c3;p=xen.git xen/arm: Sign extend TimerValue when computing the CompareValue Xen will only store the CompareValue as it can be derived from the TimerValue (ARM DDI 0487E.a section D11.2.4): CompareValue = (Counter[63:0] + SignExtend(TimerValue))[63:0] While the TimerValue is a 32-bit signed value, our implementation assumed it is a 32-bit unsigned value. Signed-off-by: Jeff Kubascik Acked-by: Julien Grall --- diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c index 08411f33a9..6d39fc944f 100644 --- a/xen/arch/arm/vtimer.c +++ b/xen/arch/arm/vtimer.c @@ -215,7 +215,7 @@ static bool vtimer_cntp_tval(struct cpu_user_regs *regs, uint32_t *r, } else { - v->arch.phys_timer.cval = cntpct + *r; + v->arch.phys_timer.cval = cntpct + (uint64_t)(int32_t)*r; if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE ) { v->arch.phys_timer.ctl &= ~CNTx_CTL_PENDING;